#include"mystdio.h"
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<stdlib.h>


MY_FILE *my_fopen(const char *path, const char *mode)
{
    int flag = 0;
    if(strcmp(mode, "r") == 0) flag |= O_RDONLY;
    else if(strcmp(mode, "w") == 0) flag |= (O_CREAT | O_WRONLY | O_TRUNC);
    else if(strcmp(mode, "a") == 0) flag |= (O_CREAT | O_WRONLY | O_APPEND);
    else{
        //..............
    }
    int fd =0;
    if(flag & O_CREAT) {
        fd = open(path,flag,0666);
    }
    else{
        fd = open(path,flag);
    }
    if(fd < 0) return NULL;

    MY_FILE* file = (MY_FILE*)malloc(sizeof(MY_FILE));
    if(file == NULL)
    {
        close(fd);
        return NULL;
    }

    //.....
}


int main()
{

}
